<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>动态路由</title>
</head>
<body>
<div id="app">
    <router-link to="/location/8">苹果</router-link>
    <router-link to="/location/9">华为</router-link>
    <router-link to="/location/10">三星</router-link>
    <router-view></router-view>
</div>
<script src="../instances/vue.js"></script>
<script src="../instances/vue-router.js"></script>
<script>
    let commons = {
      template: `<div>当前选中id为：{{$route.params.id}}</div>`
    }

    let router = new VueRouter({
      routes: [{
        path: '/location/:id',
        component: commons
      }]
    })

    let vm = new Vue({
        el: "#app",
        router
    })
</script>
</body>
</html>